package com.xuwei.treeslidemenu;

import java.awt.Color;
import java.awt.event.ActionListener;
/**
 * 菜单实体
 * @author 许伟
 * @since 2015-4-29
 */
public class Menu{
    private final Color BACKGROUND_COLOR=Color.WHITE;
    private String name;//菜单名
    private Color backgroundColor=BACKGROUND_COLOR;//设置菜单颜色
    private ActionListener actionListener=null;
   
    public Color getBackgroundColor() {
        return backgroundColor;
    }

    public void setBackgroundColor(Color backgroundColor) {
        this.backgroundColor = backgroundColor;
    }


    private Menu[] subMenus;//子菜单
    
    public Menu(String name,Menu[] subMenus) {
        this.name=name;
        this.subMenus=subMenus;
    }

    public Menu(){
        
    }
    
    
    public String getName() {
        return name;
    }

    
    public void setName(String name) {
        this.name = name;
    }

    
    public Menu[] getSubMenus() {
        return subMenus;
    }

    
    public void setSubMenus(Menu[] subMenus) {
        this.subMenus = subMenus;
    }

    //绑定事件
    public void blurActionListener(ActionListener e) {
        if(this.getSubMenus()!=null){
            throw new RuntimeException("该菜单含有系统默认事件，无法绑定指定事件！");
        }else{
            this.setActionListener(e);
        }
    }

    
    public ActionListener getActionListener() {
        return actionListener;
    }

    
    private void setActionListener(ActionListener actionListener) {
        this.actionListener = actionListener;
    }
    

}
